﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmCadCargo : Form
    {
        private CargoBL cBL;
        private cargo c;

        public FrmCadCargo(CargoBL cBL)
        {
            InitializeComponent();
            this.cBL = cBL;
            cargoBindingSource.AddNew();
        }

        public FrmCadCargo(CargoBL cBL, cargo c)
        {
            InitializeComponent();
            this.cBL = cBL;
            this.c = c;

            id_cargoTextBox.Enabled = false;
            cargoBindingSource.DataSource = c;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            cargoBindingSource.EndEdit();

            if (c == null)
                cBL.salvar((cargo)cargoBindingSource.Current, "insert");
            else
                cBL.salvar((cargo)cargoBindingSource.Current, "edit");

            MessageBox.Show("Salvo com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }

        private void FrmCadCargo_Load(object sender, EventArgs e)
        {

        }

        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
